import Vue from 'vue';
import Router from 'vue-router';

import Layout from '@/layout/index.vue';

Vue.use(Router);

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
  },
  {
    path: '',
    component: Layout,
    redirect: 'admin',
    children: [
      {
        path: 'admin',
        name: 'admin',
        component: () => import('@/views/admin/index'),
      },
      {
        path: 'introduction', // 基本信息
        name: 'Introduction',
        component: () => import('@/views/introduction/index'),
      },
      {
        path: 'job', // 求职意向
        name: 'jobIntention',
        component: () => import('@/views/jobIntention/index'),
      },
      {
        path: 'educationsal', // 教育背景
        name: 'educationsal',
        component: () => import('@/views/educationsal/index'),
      },
      {
        path: 'experience', // 工作背景
        name: 'workExperience',
        component: () => import('@/views/workExperience/index'),
      },
      {
        path: 'project', // 项目经验
        name: 'myProject',
        component: () => import('@/views/myProject/index'),
      },
      {
        path: 'skills', // 技能
        name: 'skills',
        component: () => import('@/views/skills/index'),
      },
      {
        path: 'option', // 技能
        name: 'setOptions',
        component: () => import('@/views/setOptions/index'),
      },
    ],
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true,
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true,
  },
];

export const asyncRoutes = [];
const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes,
});

const router = createRouter();

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
